package com.zhangmeng.SpringBoot3Demo.service;

import com.zhangmeng.SpringBoot3Demo.model.User;
import com.zhangmeng.SpringBoot3Demo.repository.UserRepository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangmeng_d
 * @date 2025/10/09
 */
@Service
public class UserServiceImpl implements UserService {

    private UserRepository userRepository;

    public UserServiceImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public List<User> getUsers() {
       return userRepository.findAll();
    }

    @Override
    public void addUser(User user) {
        userRepository.save(user);
    }
}
